package com.sfeir.gwt.webding.client.showcase;

import java.util.List;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sfeir.gwt.webding.client.component.Info;
import com.sfeir.gwt.webding.client.component.label.LabelCheckBox;
import com.sfeir.gwt.webding.client.component.label.LabelDateBox;
import com.sfeir.gwt.webding.client.component.label.LabelDoubleBox;
import com.sfeir.gwt.webding.client.component.label.LabelFileUpload;
import com.sfeir.gwt.webding.client.component.label.LabelIntegerBox;
import com.sfeir.gwt.webding.client.component.label.LabelListCheckBox;
import com.sfeir.gwt.webding.client.component.label.LabelListRadioButton;
import com.sfeir.gwt.webding.client.component.label.LabelPasswordBox;
import com.sfeir.gwt.webding.client.component.label.LabelTextArea;
import com.sfeir.gwt.webding.client.showcase.ShowcaseAnnotations.ShowcaseSource;


public class TabLabelOther extends LazyTab {
    /**
     * 
     */
    @ShowcaseSource
    protected Widget createTab() {
        VerticalPanel panel = new VerticalPanel();

        panel.add(new LabelTextArea("Champs TextArea"));

        LabelTextArea field2 = new LabelTextArea("Champs TextArea (80x10)", true);
        field2.setCharacterWidth(80);
        field2.setVisibleLines(10);
        panel.add(field2);

        panel.add(new LabelPasswordBox("Champs mot de passe"));

        LabelIntegerBox integer = new LabelIntegerBox("Champs Nombre entier", false);
        integer.addValueChangeHandler(new ValueChangeHandler<Integer>() {
        	@Override
        	public void onValueChange(ValueChangeEvent<Integer> event) {
        		Info.display("Nouvelle valeur : " + event.getValue());
        	}
		});
		panel.add(integer);
		LabelDoubleBox floatant = new LabelDoubleBox("Champs Nombre entier", false);
        floatant.addValueChangeHandler(new ValueChangeHandler<Double>() {
        	@Override
        	public void onValueChange(ValueChangeEvent<Double> event) {
        		Info.display("Nouvelle valeur : " + event.getValue());
        	}
		});
        panel.add(floatant);
        
        panel.add(new LabelDateBox("Champs date", true));
        
        panel.add(new LabelCheckBox("Champs case à cocher", true));
        
        LabelListRadioButton<Boolean> field6 = new LabelListRadioButton<Boolean>("Liste choix simple");
        field6.addItem("Oui", true);
        field6.addItem("Non", false);
        field6.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field6);
        
        LabelListRadioButton<Boolean> field7 = new LabelListRadioButton<Boolean>("Liste choix simple avec défaut");
        field7.addDefaultItem("Peut-être");
        field7.addItem("Oui", true);
        field7.addItem("Non", false);
        field7.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field7);
        
        LabelListCheckBox<Integer> field8 = new LabelListCheckBox<Integer>("Liste choix multiple");
        field8.addItem("Lundi", 1);
        field8.addItem("Mardi", 2);
        field8.addItem("Mercredi", 3);
        field8.addItem("Jeudi", 4);
        field8.addItem("Vendredi", 5);
        field8.addItem("Samedi", 6);
        field8.addItem("Dimanche", 7);
        field8.addValueChangeHandler(new ValueChangeHandler<List<Integer>>() {
            public void onValueChange(ValueChangeEvent<List<Integer>> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field8);
        
        panel.add(new LabelFileUpload("Champs d'envoi de fichier"));

        return panel;
    }

    @Override
    public String getDescription() {
        return "Les autres types de champs utilisable";
    }

    @Override
    public String getName() {
        return "Autres type de champs";
    }
}